package com.wc.AlgoOJ._前缀和与差分.A114;

import java.util.Scanner;

/**
 * @Author congege
 * @Description 不要62
 * http://43.138.190.70:8888/p/A114
 * @Date Created in 2023/12/8-22:55
 */
public class Main {
    static int maxN = (int) 1e6;
    // 前缀数组
    static int[] pre = new int[maxN + 1];

    public static void main(String[] args) {
        for (int i = 1; i <= maxN; i++) {
            String s = String.valueOf(i);
            if (s.contains("4") || s.contains("62")) {
                pre[i] = pre[i - 1];
            } else {
                pre[i] = pre[i - 1] + 1;
            }
        }

        Scanner sc = new Scanner(System.in);
        while (true) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            if (l == 0 && r == 0) {
                break;
            }
            System.out.println(pre[r] - pre[l - 1]);
        }
    }
}
